<template>
  <div class="search-demo">
    <div class="table" :class='{ show }'>
      <div>
        <a-form :model="form" layout="vertical" ref="searchFormRef">
          <a-row :gutter="16">
            <slot></slot>
          </a-row>
        </a-form>
      </div>
    </div>
    <div class="operate-demo">
      <div class="title">
        <a-space>
          <a-button type="outline" :disabled="loading" @click="refresh">
            <template #icon>
              <icon-loop :spin="loading"></icon-loop>
            </template>
          </a-button>
          <template v-if="slots?.default">
            <a-button type="outline" status="normal" @click="show = !show">
              <template #icon>
                <icon-filter />
              </template>
              {{ show ? $t('components.cTableSearch.60zeqjrtm8w0') : $t('components.cTableSearch.60zeqjrtqgg0') }}
            </a-button>
            <a-button :disabled="loading" type="outline" v-show="show" @click="reset">
              <template #icon>
                <icon-refresh />
              </template>
              {{$t('components.cTableSearch.60zeqjrtqso0')}}
            </a-button>
            <a-button :disabled="loading" type="primary" v-show="show" @click="search">
              <template #icon>
                <icon-search />
              </template>
              {{$t('components.cTableSearch.60zeqjrtr0w0')}}
            </a-button>
          </template>
        </a-space>
      </div>
      <div class="add">
        <a-space>
          <slot name="export"></slot>
          <slot name="playback"></slot>
          <slot name="addEquipment"></slot>
          <slot name="addEquipmentGroup"></slot>
          <slot name="add"></slot>
          <slot name="inData"></slot>
          <slot name="downloadTem"></slot>
        </a-space>
      </div>
    </div>
    <div class="search"></div>
  </div>
</template>

<script lang='ts' setup>
import { ref } from 'vue'
const slots = useSlots()
const loading = defineModel('loading', { default: false })
const searchFormRef = ref()
const emit = defineEmits(['refresh'])
const refresh = () => {
  emit('refresh')
}
// 展开操作
const show = ref(false)
//重置操作
const reset = () => {
  searchFormRef.value?.resetFields()
  for (let key in form.value){
    if(['startTime','endTime'].includes(key)){
      form.value[key] = ''
    }
  }
  refresh()
}
//搜索操作
const search = () => {
  refresh()
}
//导出操作



const form: any = defineModel('model')
// const resetForm = () => {

// }
// const visible = ref(false);
// const handleClick = () => {
//   visible.value = true;
// };
</script>

<style scoped lang="less">
.search-demo {
  background-color: var(--menu-bg-color);
  padding: 20px;
  margin-bottom: 10px;
  border-radius: 10px;

  .table {
    display: grid;
    grid-template-rows: 0fr;
    overflow: hidden;
    will-change: grid-template-rows;
    transition: grid-template-rows .1s;
    >div{
        min-height: 0;
    }
    &.show {
        grid-template-rows: 1fr;
    }
  }

  .operate-demo {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
}

:deep(.arco-btn-primary, .arco-btn-primary[type='button'], .arco-btn-primary[type='submit']) {
  color: #fff;
  background-color: var(--botton-bg-color) !important;
  border: 1px solid transparent;
}

:deep(.arco-btn-outline, .arco-btn-outline[type='button'], .arco-btn-outline[type='submit']) {
  color: var(--botton-bg-color) !important;
  background-color: transparent;
  border: 1px solid var(--botton-bg-color) !important;
}

:deep(.arco-table) {
  .arco-btn-size-medium {
    padding: 0 15px !important;
  }
}
</style>
